﻿//获取页面Id，格式：http://domin.com/index.html?123#
//返回123，否则返回-1
function get_url_id()
{
    //接受页面传值
    var uri = document.documentURI;
    var index=uri.lastIndexOf("?");
    if(index>0)
    {
        var para=uri.substr(index+1);
        var id = para.replace(/[^\d]/g, '');//去除#号
        return id;
    }
    return -1;
}

//判断是否登录
function is_login() {
    $.ajax({
        url: '/Api/IsLogin',
        type: 'post',
        dataType: 'json',
        success: function (data) {
            if (data.Code != 1) {
                //直接跳转到登录
                location.href = '/wap/login.html';
                return;
            }
            //else {
            //    //填写订单
            //    location.href = "/wap/tj_indent.html?" + eid;
            //    return;
            //}
        },
        beforeSend: function (xhr) {
            var storage = window.localStorage;
            var ticket = storage.getItem('token');
            xhr.setRequestHeader("token", ticket);
        }
    });
}